﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace XCommunity.Users
{

  /// <summary>
  /// IControlItem的一个标准实现
  /// </summary>
  public class ControlItem : IControlItem
  {


    public ControlItem( ControlConstraintDelegate conditionMethod, ControlItemType controlType )
    {
      Constraint = new ControlConstraint( conditionMethod );
      ControlType = controlType;
    }


    public ControlItem( IControlConstraint condition, ControlItemType controlType )
    {
      Constraint = condition;
      ControlType = controlType;
    }


    #region IControlItem 成员

    public bool IsSatisfied( IPrincipal user, string action, params object[] frameObjects )
    {
      return Constraint.IsSatisfied( user, action, frameObjects );
    }

    public ControlItemType ControlType
    {
      get;
      private set;
    }

    #endregion

    public IControlConstraint Constraint
    {
      get;
      private set;
    }
  }
}
